/*

*/

PLUS:
  PUSH(FP);
  MOV(FP,SP);
  PUSH(R1); //save R1
  PUSH(R2); //save R2
  MOV(R1, FPARG(1)); //R1= n
  PUSH(0);
  CALL(MAKE_SOB_INTEGER); //intialize R0=0
  DROP(1);
  CMP(R1,0);
  JUMP_EQ(PLUS_EXIT);
 L_PLUS_LOOP:
  MOV(R2,FPARG(R1+1)); //move argument n to R2
  CMP(IND(R2),T_INTEGER); //check argument type
  JUMP_EQ(PLUS_TYPE_OK);
  CMP(IND(R2),T_FRACTION); //check argument type
  JUMP_NE(TYPE_ERROR); 
PLUS_TYPE_OK:
  PUSH(R0);
  PUSH(R2);
  CALL(BINARY_PLUS);
  DROP(2);
  DECR(R1); //decrement n
  CMP(R1, IMM(0)); //check if n is 0
  JUMP_NE(L_PLUS_LOOP);
PLUS_EXIT:
  POP(R2);
  POP(R1);
  POP(FP);
  RETURN;
#include "plus.asm"
